package com.gs.seckill.config;

import com.gs.seckill.job.SecKillPreHot;
import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class JobConfig {


  @Bean
  public JobDetail jobDetail(){
    return JobBuilder.newJob(SecKillPreHot.class)
      .storeDurably()
      .build();
  }

  @Bean
  public Trigger trigger(){
    return TriggerBuilder.newTrigger()
      .forJob(jobDetail())
      .withSchedule(CronScheduleBuilder.cronSchedule("0 0 0 * * ?"))
      .startNow().build();
  }

}
